import store from 'store';

export function login(){
	return new Promise(function(resolve, reject){
		uni.request({
			url:store.state.URL+'login/login/token',
			data:{},
			header: {
				'content-type': 'application/x-www-form-urlencoded',
			},
			success: (res) => {
				uni.setStorageSync('token', res.data.token);
				store.commit('updataToken', res.data.token);
				console.log(store.state.token,'res.data.token');
				resolve(res.data.token)
			}
		});
	})
}

export function events_list() {
	return new Promise(function(resolve, reject){
		console.log(store.state.token, 'aaaaaaaaaaaaaaaaaaaaaaa')
		uni.request({
			url: store.state.URL+'hmc/mobile_terminal/mobile_select',
			method: 'POST',
			header: {
				'content-type': 'application/x-www-form-urlencoded',
			},
			data: {
				token: store.state.token,
			},
			success(res) {
				resolve(res)
			}
		});
	})
}